template.tsx 818 B

12345678910111213141516171819202122232425262728
  1. "use client";
  2. import { usePathname } from "@/i18n/routing";
  3. import { AnimatePresence, motion } from "framer-motion";
  4. import { ReactNode } from "react";
  5. const Template = ({ children }: { children: ReactNode }) => {
  6. const key = usePathname();
  7. return (
  8. <AnimatePresence mode="popLayout">
  9. <motion.div
  10. layout
  11. key={key}
  12. initial={{ x: 100, opacity: 0 }}
  13. animate={{ x: 0, opacity: 1 }}
  14. exit={{ x: 100, opacity: 0 }}
  15. transition={{
  16. duration: 0.3,
  17. ease: [0, 0.71, 0.2, 1.01],
  18. }}
  19. className={"h-[100%]"}
  20. >
  21. {children}
  22. </motion.div>
  23. </AnimatePresence>
  24. );
  25. };
  26. export default Template;